package adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import bean.AnswerCardBean;
import student.andlei.com.student.R;

public class SheetShapeListAdapter extends BaseQuickAdapter<AnswerCardBean.mlist.Questions,BaseViewHolder>{
    private boolean isCommit;
    public SheetShapeListAdapter(int layoutResId, @Nullable List<AnswerCardBean.mlist.Questions> data,boolean isCommit) {
        super(layoutResId, data);
        this.isCommit = isCommit;
    }

    @Override
    protected void convert(BaseViewHolder helper, AnswerCardBean.mlist.Questions item) {
            if(isCommit){
                //答案状态 0未批改 1正确 2错误 3未答题
                switch (item.answer_status){
                    case 0:
                        helper.getView(R.id.tv_question).setBackgroundResource(R.drawable.circle_fill_gray);
                        break;
                    case 1:
                        helper.getView(R.id.tv_question).setBackgroundResource(R.drawable.circle_fill_blue);
                        break;
                    case 2:
                        helper.getView(R.id.tv_question).setBackgroundResource(R.drawable.circle_fill_red);
                        break;
                    case 3:
                        helper.getView(R.id.tv_question).setBackgroundResource(R.drawable.circle_fill_gray);
                        break;
                }
            }else {
                //答案状态 0未批改 1正确 2错误 3未答题
                switch (item.answer_status){
                    case 0:
                        helper.getView(R.id.tv_question).setBackgroundResource(R.drawable.circle_fill_green);
                        break;
                    case 1:
                        helper.getView(R.id.tv_question).setBackgroundResource(R.drawable.circle_fill_green);
                        break;
                    case 2:
                        helper.getView(R.id.tv_question).setBackgroundResource(R.drawable.circle_fill_green);
                        break;
                    case 3:
                        helper.getView(R.id.tv_question).setBackgroundResource(R.drawable.circle_fill_gray);
                        break;
                }
            }

            helper.setText(R.id.tv_question,(helper.getAdapterPosition()+1)+"");
    }
}
